Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Let users choose the file encoding #190

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

reconman
Copy link

@reconman reconman commented Feb 6, 2022

Fixes #189

I've added some type hints and comments to the user-facing functions. Wasn't sure about the type of validator, so it's still Any.

@mechie
Copy link
Contributor

mechie commented Feb 6, 2022

As an aside, I think this would be a breaking change--Windows-only users (or anyone with a supported non-utf-8 text encoding set as their locale) may be unwittingly, or intentionally, relying on this behavior.

@mildebrandt
Copy link

I agree @mechie , more comments in #189 .

@reconman reconman changed the title Make file-encoding UTF-8 by default and let users choose Let users choose the file encoding Feb 9, 2022
@reconman
Copy link
Author

reconman commented Feb 9, 2022

I've changed it to the system default. Tested it with the value Chūnibyō demo Koi ga Shitai! in a YAML file. If I encode it as CP1252, it can be parsed on Windows. If I use UTF-8 instead, an exception is thrown.

Not really happy with copy-pasting the locale function call everywhere but I'm not a professional Python programmer, so there may be better ways.

@mildebrandt
Copy link

Thanks for your PR. Let me think a bit about the best way to handle this. Maybe instead of passing the encoding through several layers of functions, we could introduce a config mechanism.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

File encoding is always the system one and cannot be changed
3 participants